home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / H-i586-cygwin32 / i586-cygwin32 / include / mingw32 / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-04  |  9.5 KB  |  367 lines

  1. /*
  2.  * stdio.h
  3.  *
  4.  * Definitions of types and prototypes of functions for standard input and
  5.  * output.
  6.  *
  7.  * NOTE: The file manipulation functions provided by Microsoft seem to
  8.  * work with either slash (/) or backslash (\) as the path separator.
  9.  *
  10.  * This file is part of the Mingw32 package.
  11.  *
  12.  * Contributors:
  13.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  14.  *
  15.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  16.  *
  17.  *  This source code is offered for use in the public domain. You may
  18.  *  use, modify or distribute it freely.
  19.  *
  20.  *  This code is distributed in the hope that it will be useful but
  21.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  22.  *  DISCLAMED. This includes but is not limited to warranties of
  23.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24.  *
  25.  * $Revision: 1.3 $
  26.  * $Author: noer $
  27.  * $Date: 1998/10/20 01:24:49 $
  28.  *
  29.  */
  30.  
  31. #ifndef _STDIO_H_
  32. #define    _STDIO_H_
  33.  
  34. #define __need_size_t
  35. #define __need_NULL
  36. #define __need_wchar_t
  37. #define    __need_wint_t
  38. #ifndef RC_INVOKED
  39. #include <stddef.h>
  40. #endif    /* Not RC_INVOKED */
  41.  
  42.  
  43. /* Some flags for the iobuf structure provided by <paag@tid.es> */
  44. #define    _IOREAD    1
  45. #define    _IOWRT    2
  46. #define    _IORW    4
  47.  
  48. /*
  49.  * The three standard file pointers provided by the run time library.
  50.  * NOTE: These will go to the bit-bucket silently in GUI applications!
  51.  */
  52. #define    STDIN_FILENO    0
  53. #define    STDOUT_FILENO    1
  54. #define    STDERR_FILENO    2
  55.  
  56. /* Returned by various functions on end of file condition or error. */
  57. #define    EOF    (-1)
  58.  
  59. /*
  60.  * The maximum length of a file name. You should use GetVolumeInformation
  61.  * instead of this constant. But hey, this works.
  62.  *
  63.  * NOTE: This is used in the structure _finddata_t (see dir.h) so changing it
  64.  *       is probably not a good idea.
  65.  */
  66. #define    FILENAME_MAX    (260)
  67.  
  68. /*
  69.  * The maximum number of files that may be open at once. I have set this to
  70.  * a conservative number. The actual value may be higher.
  71.  */
  72. #define FOPEN_MAX    (20)
  73.  
  74. /*
  75.  * The maximum size of name (including NUL) that will be put in the user
  76.  * supplied buffer caName for tmpnam.
  77.  * NOTE: This has not been determined by experiment, but based on the
  78.  * maximum file name length above it is probably reasonable. I could be
  79.  * wrong...
  80.  */
  81. #define    L_tmpnam    (260)
  82.  
  83. /*
  84.  * The three possible buffering mode (nMode) values for setvbuf.
  85.  * NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered...
  86.  * maybe I'm testing it wrong?
  87.  */
  88. #define    _IOFBF    0    /* fully buffered */
  89. #define    _IOLBF    1    /* line buffered */
  90. #define    _IONBF    2    /* unbuffered */
  91.  
  92. /*
  93.  * The buffer size as used by setbuf such that it is equivalent to
  94.  * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
  95.  */
  96. #define    BUFSIZ    512
  97.  
  98. /* Constants for nOrigin indicating the position relative to which fseek
  99.  * sets the file position. Enclosed in ifdefs because io.h could also
  100.  * define them. (Though not anymore since io.h includes this file now.) */
  101. #ifndef    SEEK_SET
  102. #define SEEK_SET    (0)
  103. #endif
  104.  
  105. #ifndef    SEEK_CUR
  106. #define    SEEK_CUR    (1)
  107. #endif
  108.  
  109. #ifndef    SEEK_END
  110. #define SEEK_END    (2)
  111. #endif
  112.  
  113.  
  114. #ifndef    RC_INVOKED
  115.  
  116. /*
  117.  * I used to include stdarg.h at this point, in order to allow for the
  118.  * functions later on in the file which use va_list. That conflicts with
  119.  * using stdio.h and varargs.h in the same file, so I do the typedef myself.
  120.  */
  121. #ifndef _VA_LIST
  122. #define _VA_LIST
  123. typedef    char* va_list;
  124. #endif
  125.  
  126. /*
  127.  * The structure underlying the FILE type.
  128.  *
  129.  * I still believe that nobody in their right mind should make use of the
  130.  * internals of this structure. Provided by Pedro A. Aranda Gutiirrez
  131.  * <paag@tid.es>.
  132.  */
  133. #ifndef _FILE_DEFINED
  134. #define    _FILE_DEFINED
  135. typedef struct _iobuf
  136. {
  137.     char*    _ptr;
  138.     int    _cnt;
  139.     char*    _base;
  140.     int    _flag;
  141.     int    _file;
  142.     int    _charbuf;
  143.     int    _bufsiz;
  144.     char*    _tmpfname;
  145. } FILE;
  146. #endif    /* Not _FILE_DEFINED */
  147.  
  148.  
  149. /*
  150.  * The standard file handles
  151.  */
  152. extern FILE (*__imp__iob)[];    /* A pointer to an array of FILE */
  153.  
  154. #define _iob    (*__imp__iob)    /* An array of FILE */
  155.  
  156. #define stdin    (&_iob[STDIN_FILENO])
  157. #define stdout    (&_iob[STDOUT_FILENO])
  158. #define stderr    (&_iob[STDERR_FILENO])
  159.  
  160.  
  161. #ifdef __cplusplus
  162. extern "C" {
  163. #endif
  164.  
  165. /*
  166.  * File Operations
  167.  */
  168.  
  169. FILE*    fopen (const char* szFileName, const char* szMode);
  170. FILE*    freopen (const char* szNewFileName, const char* szNewMode,
  171.          FILE* fileChangeAssociation);
  172. int    fflush (FILE* fileFlush);
  173. int    fclose (FILE* fileClose);
  174. int    remove (const char* szFileName);
  175. int    rename (const char* szOldFileName, const char* szNewFileName);
  176. FILE*    tmpfile ();
  177. char*    tmpnam (char caName[]);
  178. char*    _tempnam (char* szPath, const char* szPrefix);
  179.  
  180. #ifndef    NO_OLDNAMES
  181. char*    tempnam (char* szPath, const char* szPrefix);
  182. #endif
  183.  
  184. int    setvbuf (FILE* fileSetBuffer, char* caBuffer, int nMode,
  185.          size_t sizeBuffer);
  186.  
  187. void    setbuf (FILE* fileSetBuffer, char* caBuffer);
  188.  
  189. /*
  190.  * Formatted Output
  191.  */
  192.  
  193. int    fprintf (FILE* filePrintTo, const char* szFormat, ...);
  194. int    printf (const char* szFormat, ...);
  195. int    sprintf (char* caBuffer, const char* szFormat, ...);
  196. int    vfprintf (FILE* filePrintTo, const char* szFormat, va_list varg);
  197. int    vprintf (const char* szFormat, va_list varg);
  198. int    vsprintf (char* caBuffer, const char* szFormat, va_list varg);
  199.  
  200. /* Wide character versions */
  201. int    fwprintf (FILE* filePrintTo, const wchar_t* wsFormat, ...);
  202. int    wprintf (const wchar_t* wsFormat, ...);
  203. int    swprintf (wchar_t* wcaBuffer, const wchar_t* wsFormat, ...);
  204. int    vfwprintf (FILE* filePrintTo, const wchar_t* wsFormat, va_list varg);
  205. int    vwprintf (const wchar_t* wsFormat, va_list varg);
  206. int    vswprintf (wchar_t* wcaBuffer, const wchar_t* wsFormat, va_list varg);
  207.  
  208. /*
  209.  * Formatted Input
  210.  */
  211.  
  212. int    fscanf (FILE* fileReadFrom, const char* szFormat, ...);
  213. int    scanf (const char* szFormat, ...);
  214. int    sscanf (const char* szReadFrom, const char* szFormat, ...);
  215.  
  216. /* Wide character versions */
  217. int    fwscanf (FILE* fileReadFrom, const wchar_t* wsFormat, ...);
  218. int    wscanf (const wchar_t* wsFormat, ...);
  219. int    swscanf (wchar_t* wsReadFrom, const wchar_t* wsFormat, ...);
  220.  
  221. /*
  222.  * Character Input and Output Functions
  223.  */
  224.  
  225. int    fgetc (FILE* fileRead);
  226. char*    fgets (char* caBuffer, int nBufferSize, FILE* fileRead);
  227. int    fputc (int c, FILE* fileWrite);
  228. int    fputs (const char* szOutput, FILE* fileWrite);
  229. int    getc (FILE* fileRead);
  230. int    getchar ();
  231. char*    gets (char* caBuffer);    /* Unsafe: how does gets know how long the
  232.                  * buffer is? */
  233. int    putc (int c, FILE* fileWrite);
  234. int    putchar (int c);
  235. int    puts (const char* szOutput);
  236. int    ungetc (int c, FILE* fileWasRead);
  237.  
  238. /* Wide character versions */
  239. wint_t    fgetwc (FILE* fileRead);
  240. wint_t    fputwc (wchar_t wc, FILE* fileWrite);
  241. wint_t    ungetwc (wchar_t wc, FILE* fileWasRead);
  242.  
  243.  
  244. /*
  245.  * Not exported by CRTDLL.DLL included for reference purposes.
  246.  */
  247. #if 0
  248. wchar_t*    fgetws (wchar_t* wcaBuffer, int nBufferSize, FILE* fileRead);
  249. int        fputws (const wchar_t* wsOutput, FILE* fileWrite);
  250. int        getwc (FILE* fileRead);
  251. int        getwchar ();
  252. wchar_t*    getws (wchar_t* wcaBuffer);
  253. int        putwc (wchar_t wc, FILE* fileWrite);
  254. int        putws (const wchar_t* wsOutput);
  255. #endif    /* 0 */
  256.  
  257. /* NOTE: putchar has no wide char equivalent even in tchar.h */
  258.  
  259.  
  260. /*
  261.  * Direct Input and Output Functions
  262.  */
  263.  
  264. size_t    fread (void* pBuffer, size_t sizeObject, size_t sizeObjCount,
  265.         FILE* fileRead);
  266. size_t    fwrite (const void* pObjArray, size_t sizeObject, size_t sizeObjCount,
  267.         FILE* fileWrite);
  268.  
  269.  
  270. /*
  271.  * File Positioning Functions
  272.  */
  273.  
  274. int    fseek    (FILE* fileSetPosition, long lnOffset, int nOrigin);
  275. long    ftell    (FILE* fileGetPosition);
  276. void    rewind    (FILE* fileRewind);
  277.  
  278. /*
  279.  * An opaque data type used for storing file positions... The contents of
  280.  * this type are unknown, but we (the compiler) need to know the size
  281.  * because the programmer using fgetpos and fsetpos will be setting aside
  282.  * storage for fpos_t structres. Actually I tested using a byte array and
  283.  * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
  284.  * Perhaps an unsigned long? TODO?
  285.  */
  286. typedef long    fpos_t;
  287.  
  288. int    fgetpos    (FILE* fileGetPosition, fpos_t* pfpos);
  289. int    fsetpos (FILE* fileSetPosition, fpos_t* pfpos);
  290.  
  291. /*
  292.  * Error Functions
  293.  */
  294.  
  295. void    clearerr (FILE* fileClearErrors);
  296. int    feof (FILE* fileIsAtEnd);
  297. int    ferror (FILE* fileIsError);
  298. void    perror (const char* szErrorMessage);
  299.  
  300.  
  301. #ifndef __STRICT_ANSI__
  302.  
  303. /*
  304.  * Pipes
  305.  */
  306. FILE*    _popen (const char* szPipeName, const char* szMode);
  307. int    _pclose (FILE* pipeClose);
  308.  
  309. #ifndef NO_OLDNAMES
  310. FILE*    popen (const char* szPipeName, const char* szMode);
  311. int    pclose (FILE* pipeClose);
  312. #endif
  313.  
  314. /* The wide character version, only available in MSVCRT DLL versions, not
  315.  * CRTDLL. */
  316. #ifdef __MSVCRT__
  317. FILE*    _wpopen (const wchar_t* szPipeName, const wchar_t* szMode);
  318.  
  319. #ifndef NO_OLDNAMES
  320. #if 0
  321. FILE*    wpopen (const wchar_t* szPipeName, const wchar_t* szMode);
  322. #else /* Always true */
  323. /*
  324.  * The above prototypeing is not possible unless the wpopen export is added
  325.  * to moldnames, which can't be done unless we make separate moldnames.def
  326.  * files for every supported runtime. For the time being we use a define
  327.  * instead. Pedro's modified dlltool should take care of this I think.
  328.  */
  329. #define wpopen _wpopen
  330. #endif    /* Always true */
  331.  
  332. #endif /* not NO_OLDNAMES */
  333. #endif /* MSVCRT runtime */
  334.  
  335. /*
  336.  * Other Non ANSI functions
  337.  */
  338. int    _fgetchar ();
  339. int    _fputchar (int c);
  340. FILE*    _fdopen (int nHandle, const char* szMode);
  341. wint_t    _fgetwchar(void);
  342. wint_t    _fputwchar(wint_t c);
  343. int    _fileno (FILE* fileGetHandle);
  344. int    _getw (FILE*);
  345. int    _putw (int, FILE*);
  346.  
  347. #ifndef _NO_OLDNAMES
  348. int    fgetchar ();
  349. int    fputchar (int c);
  350. FILE*    fdopen (int nHandle, const char* szMode);
  351. wint_t    fgetwchar(void);
  352. wint_t    fputwchar(wint_t c);
  353. int    fileno (FILE* fileGetHandle);
  354. int    getw (FILE*);
  355. int    putw (int, FILE*);
  356. #endif    /* Not _NO_OLDNAMES */
  357.  
  358. #endif    /* Not __STRICT_ANSI__ */
  359.  
  360. #ifdef __cplusplus
  361. }
  362. #endif
  363.  
  364. #endif    /* Not RC_INVOKED */
  365.  
  366. #endif /* _STDIO_H_ */
  367.